﻿--#include "data\functions\Guild\GuildContendWar.lua" once --行会争夺战
local npcId = 162
NpcDialog[npcId] = {}
local t = NpcDialog[npcId]

t.main = function(sysarg)
	
	local rate = math.floor(GlobalConfig.guildSeigeTaxRate/100)

	local var = System.getStaticVar()
	local dvar = System.getDyanmicVar()

	local strCond		= string.format(Lang.GuildLang.GuildSeige030, rate, var.szGuildContendTaxCanGet or 0, var.szGuildContendTaxValue or 0)

	local strDesc 		= ""
	local okBtn 		= ""			--{按钮;样式;按钮名;函数名;描述}
	local strBtnList 	= ""

	strDesc = Lang.GuildLang.GuildSeige031
	if Guild.getContendCityOwner() == Actor.getActorId(sysarg) and var.guildContendTaxGetState == 0 and dvar.guildContendTaxCanGet == 1 then
		okBtn 		= "{btn;0;".. Lang.ScriptTips.ButtonGetTax ..";%s;}"			--{按钮;样式;按钮名;函数名;描述}
		strBtnList 	= strBtnList .. string.format(okBtn, "GetTax")
	else
		okBtn 		= "{btn;0;".. Lang.ScriptTips.ButtonLeave ..";%s;}"			--{按钮;样式;按钮名;函数名;描述}
		strBtnList 	= strBtnList .. string.format(okBtn, "Leave")
	end

	local pack = DataPack.allocPacket(sysarg, LogicCmd.npcDialogSys.sysID, LogicCmd.npcDialogSys.sub.sNpcDlgData)
	DataPack.writeUint64(pack, Actor.getNpc(sysarg))
	DataPack.writeByte(pack, NpcDialogType.LLCSNpcDlg)
	DataPack.writeString(pack, strCond)
	DataPack.writeString(pack, strDesc)
	DataPack.writeString(pack, strBtnList)
	DataPack.writeChar(pack, -1)
	DataPack.writeByte(pack, 0);
	DataPack.flush(pack)
end

t.GetTax = function(sysarg)
	local state = GetContendGuildTax(sysarg)
	if state then
		t.main(sysarg)
	end
end


t.Leave = function(sysarg)
	Actor.closeNPCDialog(sysarg)
end






